﻿<!DOCTYPE html>
<%@ page language="java" import="com.newcrm.config.Const,com.newcrm.bean.*,com.newcrm.util.*,java.util.*,com.newcrm.db.DealFieldManager" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
  Map<String, Object> dealInfo = (Map<String, Object>)request.getAttribute("dealInfo");
  List<ExtInfo> extInfos = (List<ExtInfo>)request.getAttribute("extInfos");
  List<Map<String, Object>> fields = (List<Map<String, Object>>) request.getAttribute("fields");

  String responsibleUserId = (String) dealInfo.get("ResponsibleUserId");

  User user = (User) session.getAttribute("user");
  Map<Integer, CompanyInfo> companys = (Map<Integer, CompanyInfo>) application.getAttribute(Const.APPLICATION_COMPANYS);
  CompanyInfo companyInfo = companys.get(Integer.valueOf(user.companyId));
  List<Map<String, Object>> dealCategory = companyInfo.dealCategorys;
  List<User> users = companyInfo.users;

  String categoryName = "";
  int categoryId = (Integer) dealInfo.get("CategoryId");

  if (dealCategory != null) {
    for (Map<String, Object> category:dealCategory) {
      if (categoryId == (Integer)category.get("DealCategoryId")) {
        categoryName = (String)category.get("DealCategoryName");
        break;
      }
    }
  }

%>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>企客宝</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/mobileV2/css/iconfont.css?ver=<%=Const.VERSION%>">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/mobileV2/css/sm.css?ver=<%=Const.VERSION%>">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/mobileV2/css/sm-extend.min.css?ver=<%=Const.VERSION%>">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/mobileV2/css/mobile.css?ver=<%=Const.VERSION%>">

    <script type='text/javascript' src='<%=request.getContextPath()%>/mobileV2/script/zepto.min.js?ver=<%=Const.VERSION%>' charset='utf-8'></script>
    <script type='text/javascript' src='<%=request.getContextPath()%>/mobileV2/script/sm.min.js?ver=<%=Const.VERSION%>' charset='utf-8'></script>
    <script type='text/javascript' src='<%=request.getContextPath()%>/mobileV2/script/sm-extend.min.js?ver=<%=Const.VERSION%>' charset='utf-8'></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/script/moment.min.js"></script>
    <script type='text/javascript' src='<%=request.getContextPath()%>/mobileV2/script/mobile.js?ver=<%=Const.VERSION%>' charset='utf-8'></script>
    <jsp:include page="mobileCommonJS.jsp" flush="true"/>
  </head>
  <body>
    <div class="page-group">
      <div class="page" id="page-dealDetail">
        <input type="hidden" id="dealId" value="<%=dealInfo.get("DealId")%>">
        <input type="hidden" id="dealName" value="<%=Util.HTMLEncode((String) dealInfo.get("Name"))%>">
        <header class="bar bar-nav">
          <a class="button button-link button-nav pull-left back" href="#">
            <span class="icon iconfont icon-left"></span>
          </a>
          <h1 class='title'>销售机会详细</h1>
        </header>
        <div class="content">
          <div class="content-padded">
            <div class="customer-title">
              <i class="icon iconfont icon-deal"></i>
              <div class="customer-title-name">
                <span><%=Util.HTMLEncode((String) dealInfo.get("Name"))%></span>
              </div>
            </div>
          </div>

          <div class="buttons-tab margin-top-20">
            <a href="#tab1" class="tab-link active button">联系记录</a>
            <a href="#tab2" class="tab-link button">基本信息</a>
          </div>

          <div class="content-block">
            <div class="tabs">
              <div id="tab1" class="tab active">
                <div class="content-block">
                  <p>
                    <a href="#" id="link-add-deal-note" class="button button-success button-big button-fill">添加备注</a>
                  </p>
                </div>
                <div class="content-block no-padding" id="deal-note-list"></div>
              </div>
              <div id="tab2" class="tab">
                <div class="list-block smallfont">
                  <ul>
                    <li class="item-content" id="customer-category-container">
                      <div class="item-inner">
                        <div class="item-title">销售机会类型</div>
                        <div class="item-after"><%=Util.HTMLEncode(categoryName)%></div>
                      </div>
                    </li>
                    <li class="item-content">
                      <div class="item-inner">
                        <div class="item-title">负责人</div>
                        <div class="item-after"><%=Util.getUserNameById(responsibleUserId, users)%></div>
                      </div>
                    </li>
                    <li class="item-content">
                      <div class="item-inner">
                        <div class="item-title">创建时间</div>
                        <div class="item-after"><%=dealInfo.get("CreateDate")%></div>
                      </div>
                    </li>
                    <li class="item-content">
                      <div class="item-inner">
                        <div class="item-title">金额</div>
                        <div class="item-after"><%=dealInfo.get("Price")%></div>
                      </div>
                    </li>
                    <li class="item-content">
                      <div class="item-inner">
                        <div class="item-title">提成</div>
                        <div class="item-after"><%=dealInfo.get("Commission")%></div>
                      </div>
                    </li>
                  </ul>
                </div>

                <div class="list-block smallfont">
                  <ul>
                    <%
                    for (ExtInfo extInfo : extInfos) {
                      if (extInfo.info1 == null || extInfo.info1.trim().length() == 0) {
                        continue;
                      }
                    %>
                    <li class="item-content">
                      <div class="item-inner">
                        <div class="item-title"><%=DealFieldManager.getFieldName(extInfo.type, fields)%></div>
                        <div class="item-after"><%=Util.HTMLEncode(extInfo.info1)%></div>
                      </div>
                    </li>
                    <%}%>
                    <li class="item-content">
                      <div class="item-inner">
                        <div class="item-title">简介</div>
                        <div class="item-after"><%=Util.HTMLEncode((String)dealInfo.get("Note"))%></div>
                      </div>
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="popup" id="popup-new-deal-note">
        <div class="content-block">
          <p class="text-center">添加备注</p>
          <div class="list-block">
            <textarea id="deal-note-remark" placeholder="添加备注"></textarea>
          </div>
          <div class="content-block">
            <div class="row">
              <div class="col-50"><a href="#" class="close-popup button button-big button-fill button-danger">取消</a></div>
              <div class="col-50"><a href="#" id="link-update-deal-note" class="button button-big button-fill button-success">确定</a></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>